Example
In [1]:
Copied!
import geopandas as gpd
import geodatasets as gds
nyc_dataset_path = gds.get_path('nybb')
nyc = gpd.read_file(nyc_dataset_path)
import geopandas as gpd
import geodatasets as gds
nyc_dataset_path = gds.get_path('nybb')
nyc = gpd.read_file(nyc_dataset_path)
Downloading file 'nybb_16a.zip' from 'https://www.nyc.gov/assets/planning/download/zip/data-maps/open-data/nybb_16a.zip' to '/home/runner/.cache/geodatasets'.
Extracting 'nybb_16a/nybb.shp' from '/home/runner/.cache/geodatasets/nybb_16a.zip' to '/home/runner/.cache/geodatasets/nybb_16a.zip.unzip'
Extracting 'nybb_16a/nybb.shx' from '/home/runner/.cache/geodatasets/nybb_16a.zip' to '/home/runner/.cache/geodatasets/nybb_16a.zip.unzip'
Extracting 'nybb_16a/nybb.dbf' from '/home/runner/.cache/geodatasets/nybb_16a.zip' to '/home/runner/.cache/geodatasets/nybb_16a.zip.unzip'
Extracting 'nybb_16a/nybb.prj' from '/home/runner/.cache/geodatasets/nybb_16a.zip' to '/home/runner/.cache/geodatasets/nybb_16a.zip.unzip'
To render HTML content in a Jupyter notebook, you can use the IPython.display module.
In [2]:
Copied!
from IPython.display import display, HTML, IFrame
nyc.explore()
from IPython.display import display, HTML, IFrame
nyc.explore()
Out[2]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [3]:
Copied!
from plotly import express as px
px.choropleth_mapbox(nyc, locations='BoroCode', color='BoroName')
from plotly import express as px
px.choropleth_mapbox(nyc, locations='BoroCode', color='BoroName')
In [4]:
Copied!
display(HTML(px.scatter(nyc, x='Shape_Leng', y='Shape_Area').to_html()))
display(HTML(px.scatter(nyc, x='Shape_Leng', y='Shape_Area').to_html()))